home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / domacnost a kancelar / joomla / Joomla_1.5.4-Stable-Full_Package.exe / plugins / xmlrpc / joomla.php < prev    next >
PHP Script  |  2008-07-06  |  3KB  |  111 lines

  1. <?php
  2. /**
  3. * @version        $Id: joomla.php 10381 2008-06-01 03:35:53Z pasamio $
  4. * @package        Joomla
  5. * @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  6. * @license        GNU/GPL, see LICENSE.php
  7. * Joomla! is free software. This version may have been modified pursuant
  8. * to the GNU General Public License, and as distributed it includes or
  9. * is derivative of works licensed under the GNU General Public License or
  10. * other free or open source software licenses.
  11. * See COPYRIGHT.php for copyright notices and details.
  12. */
  13.  
  14. // no direct access
  15. defined( '_JEXEC' ) or die( 'Restricted access' );
  16.  
  17. jimport('joomla.plugin.plugin');
  18.  
  19. /**
  20.  * Joomla! Base XML-RPC Plugin
  21.  *
  22.  * @package XML-RPC
  23.  * @since 1.5
  24.  */
  25. class plgXMLRPCJoomla extends JPlugin
  26. {
  27.  
  28.     /**
  29.      * Constructor
  30.      *
  31.      * For php4 compatability we must not use the __constructor as a constructor for plugins
  32.      * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
  33.      * This causes problems with cross-referencing necessary for the observer design pattern.
  34.      *
  35.      * @param object $subject The object to observe
  36.      * @param object $params  The object that holds the plugin parameters
  37.      * @since 1.5
  38.      */
  39.     function plgXMLRPCJoomla(& $subject, $config)
  40.     {
  41.         parent::__construct($subject, $config);
  42.     }
  43.  
  44.     /**
  45.      * Get available web services for this plugin
  46.      *
  47.      * @access    public
  48.      * @return    array    Array of web service descriptors
  49.      * @since    1.5
  50.      */
  51.     function onGetWebServices()
  52.     {
  53.         global $xmlrpcString;
  54.  
  55.         // Initialize variables
  56.         $services = array();
  57.  
  58.         // Site search service
  59.         $services['joomla.searchSite'] = array(
  60.             'function' => 'plgXMLRPCJoomlaServices::searchSite',
  61.             'docstring' => 'Searches a remote site.',
  62.             'signature' => array(array($xmlrpcString, $xmlrpcString, $xmlrpcString))
  63.             );
  64.  
  65.         return $services;
  66.     }
  67. }
  68.  
  69. class plgXMLRPCJoomlaServices
  70. {
  71.     /**
  72.      * Remote Search method
  73.      *
  74.      * The sql must return the following fields that are used in a common display
  75.      * routine: href, title, section, created, text, browsernav
  76.      *
  77.      * @param    string    Target search string
  78.      * @param    string    mathcing option, exact|any|all
  79.      * @param    string    ordering option, newest|oldest|popular|alpha|category
  80.      * @return    array    Search Results
  81.      * @since    1.5
  82.      */
  83.     function searchSite($searchword, $phrase='', $order='')
  84.     {
  85.         global $mainframe;
  86.  
  87.         // Initialize variables
  88.         $db        =& JFactory::getDBO();
  89.  
  90.         // Prepare arguments
  91.         $searchword    = $db->getEscaped( trim( $searchword ) );
  92.         $phrase        = '';
  93.         $ordering    = '';
  94.  
  95.         // Load search plugins and fire the onSearch event
  96.         JPluginHelper::importPlugin( 'search' );
  97.         $results = $mainframe->triggerEvent( 'onSearch', array( $searchword, $phrase, $ordering ) );
  98.  
  99.         // Iterate through results building the return array
  100.         require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_search'.DS.'helpers'.DS.'search.php');
  101.  
  102.         foreach ($results as $i=>$rows)
  103.         {
  104.             foreach ($rows as $j=>$row) {
  105.                 $results[$i][$j]->href = eregi('^(http|https)://', $row->href) ? $row->href : JURI::root().'/'.$row->href;
  106.                 $results[$i][$j]->text = SearchHelper::prepareSearchContent( $row->text, 200, $searchword);
  107.             }
  108.         }
  109.         return $results;
  110.     }
  111. }